﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jxym.DBUtility;
using Jxym.wlkc2011.Module.CMS.MODEL;

namespace Jxym.wlkc2011
{
    public partial class desc : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.Params["sitename"] != null && Request.Params["m"] != null)
                {
                    sitename = Request.Params["sitename"];

                    m = Request.Params["m"];

                    if (Request.Params["c"] != null)
                    {
                        LoadDesc(Request.Params["c"]);
                    }
                    else
                    {
                        LoadDesc(m);
                    }
                }
            }
        }

        private void LoadDesc(string mid)
        {
            MsSqlDal<Cms_ContentClass> ccc = new MsSqlDal<Cms_ContentClass>();

            Cms_ContentClass cccInfo = ccc.GetModel(mid);

            if (cccInfo != null)
            {
                labMenuTitle.Text = cccInfo.Title;
            }

            MsSqlDal<Cms_Content> cc = new MsSqlDal<Cms_Content>();

            IList<Cms_Content> ccList = cc.GetList("ContentClassID=" + mid, null, "", 0);

            if (ccList.Count > 1)
            {
                p_desclr.Visible = false;
                listlr.Visible = true;
                Label1.Visible = false;
                Repeater1.DataSource = ccList;
                Repeater1.DataBind();
            }
            else if (ccList.Count == 1)
            {
                p_desclr.Visible = true;
                listlr.Visible = false;
                Label1.Visible = false;
                labTitle.Text = ccList[0].Title;
                labUser.Text = ccList[0].AddUser;
                labAddTime.Text = ccList[0].AddTime.ToString("yyyy-MM-dd");
                labContent.Text = Module.CMS.Public.cmsPublic.ViewContent(sitename, ccList[0], "985px", "570px");
            }
            else
            {
                Label1.Visible = true;
                p_desclr.Visible = false;
                listlr.Visible = false;
            }
        }

        public string sitename { get; set; }
        public string m { get; set; }
    }
}